package msu.ml.data.level2;

/**
 * The SiteInfo class holds information about
 * a radar site.
 *
 * @author Reginald M Mead
 * @version 1.0
 */
public class SiteInfo 
{

	protected String call;
	protected String city;
	protected int height;
	protected int id;
	protected int latDegrees;
	protected int latMinutes;
	protected int latSeconds;
	protected int longDegrees;
	protected int longMinutes;
	public static final int LongPulse = 4630;
	protected int longSeconds;
	public static final int ShortPulse = 1530;
	protected String state;

	/**
	 * Create a new empty site info object
	 *
	 */
	public SiteInfo()
	{

	}

	/**
	 * Create a site info object by parsing the given 
	 * tab delimited string.
	 * 
	 * @param infoString info for site
	 */
	public SiteInfo(String infoString)
	{
		String [] fields = infoString.split("\\s+");
		if(fields.length < 11)
			return;

		try
		{
			this.id = Integer.parseInt(fields[0]);
			this.call = fields[1];
			this.city = fields[2];
			this.state = fields[3];
			this.latDegrees = Integer.parseInt(fields[4]);
			this.latMinutes = Integer.parseInt(fields[5]);
			this.latSeconds = Integer.parseInt(fields[6]);
			this.longDegrees = Integer.parseInt(fields[7]);
			this.longMinutes = Integer.parseInt(fields[8]);
			this.longSeconds = Integer.parseInt(fields[9]);
			this.height = Integer.parseInt(fields[10]);
		}
		catch(NumberFormatException e)
		{
			System.out.println(e.getMessage());
		}
	}

	/**
	 * Get the call sign of this site (eg KILX)
	 *
	 * @return site call sign
	 */
	public String getCall()
	{
		return this.call;
	}

	/**
	 * Get the city where this radar site resides
	 *
	 * @return city
	 */
	public String getCity()
	{
		return this.city;
	}

	/**
	 * Get the height of this site above sea level (meters).
	 *
	 * @return height of radar site
	 */
	public int getHeight()
	{
		return this.height;
	}

	/**
	 * Get the site ID of this radar
	 *
	 * @return site ID
	 */
	public int getId()
	{
		return this.id;
	}

	/**
	 * Get the degrees portion of the latitude
	 * for this site.
	 *
	 * @return the degrees of latitude for this site
	 */
	public int getLatitudeDegrees()
	{
		return this.latDegrees;
	}

	/**
	 * Get the minutes portion of the latitude
	 * for this site.
	 *
	 * @return the minutes of latitude for this site
	 */
	public int getLatitudeMinutes()
	{
		return this.latMinutes;
	}

	/**
	 * Get the seconds portion of the latitude
	 * for this site.
	 *
	 * @return the seconds of latitude for this site
	 */
	public int getLatitudeSeconds()
	{
		return this.latSeconds;
	}

	/**
	 * Get the degrees portion of the longitude
	 * for this site.
	 *
	 * @return the degrees of longitude for this site
	 */
	public int getLongitudeDegrees()
	{
		return this.longDegrees;
	}

	/**
	 * Get the minutes portion of the longitude
	 * for this site.
	 *
	 * @return the minutes of longitude for this site
	 */
	public int getLongitudeMinutes()
	{
		return this.longMinutes;
	}

	/**
	 * Get the seconds portion of the longitude
	 * for this site.
	 *
	 * @return the seconds of longitude for this site
	 */
	public int getLongitudeSeconds()
	{
		return this.longSeconds;
	}

	/**
	 * Get the state that this site resides in. Given as
	 * a two letter code
	 *
	 * @return state containing site
	 */
	public String getState()
	{
		return this.state;
	}

	/**
	 * Get a string representation of this site info
	 *
	 * @return Printable version of site info instance
	 */
	public String toString()
	{
		return "City: " + getCity()+ "\n" +
			"State: " + getState()+ "\n" +
			"Height: " + getHeight()+ "\n" +
			"Location: [" +
			getLatitudeDegrees() + ":" +
			getLatitudeMinutes() + ":" +
			getLatitudeSeconds() + "," +
			getLongitudeDegrees() + ":" +
			getLongitudeMinutes() + ":" +
			getLongitudeSeconds() + "]";
	}

}
